package com.study.service.impl.rabbit.direct.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;



/**
 * @desc:
 * @author: panxiyi
 * @date: 2023/5/11 8:27 下午
 */

// 为测试
//@Configuration
public class RabbitConfigDirect {

    @Bean
    public Queue directQueue() {
        // 是否持久化 是否当前连接专用，默认false；连接关闭后，默认删除队列； 是否自动删除，默认false
        return new Queue("direct_queue", true, true, true);
    }

    @Bean
    public Queue directQueue2() {
        return new Queue("direct_queue2", true, true, true);
    }



    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange("directExchange");
    }

    @Bean
    public Binding bindingDerect2() {
        return BindingBuilder.bind(directQueue()).to(directExchange()).with("direct");
    }

    @Bean
    public Binding bindingDerect() {
        return BindingBuilder.bind(directQueue2()).to(directExchange()).with("direct2");
    }

}
